<?php

namespace App\Http\Resources\Api;

use App\Models\Tenant;
use Illuminate\Http\Resources\Json\JsonResource;

class MemberCardResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $tenant = Tenant::find($this->tenant_id);
        $cover_url = config('app.url') . "uploads/{$tenant->admin_prefix}/" . $this->cover_url;
        return [
            'id'=>$this->id,
            'name' => $this->name,
            'price' => $this->price,
            'days' => $this->days,
            'count' => $this->count,
            'cover_url' => $cover_url,
            'market_price' => $this->market_price,
            'is_enable' => $this->is_enable,
            'remark' => $this->remark,
            'created_at'=>(string)$this->created_at,
            'updated_at'=>(string)$this->updated_at
        ];
    }
}
